package visao.servicos;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import util.Criptografia;
import controle.DisciplinaControle;
import modelo.bean.Disciplina;

public class ServicoDisciplina {
	private Criptografia cript;

	private DisciplinaControle disciplinaControle;

	public ServicoDisciplina() {
		disciplinaControle = new DisciplinaControle(new Disciplina());
		cript = Criptografia.getInstance();
	}
	
	@POST
	@Path("/salvar")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public String salvar(Disciplina disciplina) {
		try {
			disciplinaControle.setDisciplina(disciplina);
			disciplinaControle.criar();
		} catch (Exception e) {
			System.out.println("Erro ao salvar Usuário: " + e.getMessage());
			e.printStackTrace();
			return "Erro ao salvar";
		}
		return "Sucesso ao salvar";
	}
	
}
